<?php

namespace Zhaoqinghuan\Weather;

class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
    // 声明为允许服务提供器延迟加载
    protected $defer = TRUE;

    // 注册服务为服务提供者
    public function register()
    {
        $this->app->singleton(Weather::class, function(){
            return new Weather(config('services.weather.key'));
        });

        // 为服务注册别名
        $this->app->alias(Weather::class, 'weather');
    }

    // 服务提取
    public function provides()
    {
        return [Weather::class, 'weather'];
    }
}
